home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
os2tools
/
bnklysrc
/
b_flofil.c
< prev
next >
Wrap
Text File
|
1989-07-08
|
6KB
|
215 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software <no-Inc> */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / No-Cost<no-tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
/* */
/* */
/* BinkleyTerm .FLO file Processor */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
/* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
/* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
/* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
/* ARE ABLE TO REACH WITH THE AUTHORS. */
/* */
/* */
/* The Authors can be reached at the following addresses: */
/* */
/* Robert C. Hartman Vincent E. Perriello */
/* Spark Software VEP Software */
/* 427-3 Amherst Street 111 Carroll Street */
/* CS2032, Suite 232 Naugatuck, CT 06770 */
/* Nashua, NH 03061 */
/* */
/* FidoNet 1:132/101 FidoNet 1:141/491 */
/* Data (603) 888-8179 Data (203) 729-7569 */
/* */
/* Please feel free to contact us at any time to share your comments */
/* about our software and/or licensing policies. */
/* */
/* */
/*--------------------------------------------------------------------------*/
#include <signal.h>
#include <ctype.h>
#include <io.h>
#include <conio.h>
#include <string.h>
#define WAZOO_SECTION
#include "com.h"
#include "xfer.h"
#include "zmodem.h"
#include "keybd.h"
#include "sbuf.h"
#include "sched.h"
#include "externs.h"
#include "prototyp.h"
#define rb_plus "r+b"
extern int WaZOO_callback (char *);
static int fsent;
#define NUM_FLAGS 4
/*--------------------------------------------------------------------------*/
/* do_FLOfile (send files listed in .FLO files) */
/* returns TRUE (1) for good xfer, FALSE (0) for bad */
/*--------------------------------------------------------------------------*/
int do_FLOfile (ext_flags,callback)
char *ext_flags;
int (*callback)(char *);
{
FILE *fp;
char fname[80];
char s[80];
char *sptr;
char *HoldName;
int c;
int i,j;
struct stat buf;
long current, last_start;
HoldName = HoldAreaNameMunge(called_zone);
/*--------------------------------------------------------------------*/
/* Send files listed in ?LO files (attached files) */
/*--------------------------------------------------------------------*/
for (c = 0; c < strlen (ext_flags); c++)
{
#ifndef JACK_DECKER
if (caller && (ext_flags[c] == 'H'))
continue;
#endif
sprintf (fname, "%s%04x%04x.%cLO",
HoldName, called_net, called_node, ext_flags[c]);
errno = 0;
if (!stat (fname, &buf))
{
errno = 0;
fp = fopen (fname, rb_plus);
if (got_error (OPEN_msg, fname))
{
continue;
}
current = 0L;
while (!feof (fp))
{
s[0] = 0;
last_start = current;
fgets (s, 79, fp);
if (got_error (READ_msg, fname))
s[0] = 0;
sptr = s;
for (i = 0; sptr[i]; i++)
if (sptr[i] <= ' ')
sptr[i] = 0;
current = ftell (fp);
if (sptr[0] == TRUNC_AFTER)
{
sptr++;
i = TRUNC_AFTER;
}
else if (sptr[0] == SHOW_DELETE_AFTER)
{
sptr++;
i = SHOW_DELETE_AFTER;
}
else i = NOTHING_AFTER;
if (!sptr[0])
{
continue;
}
if (sptr[0] != '~')
{
if (stat (sptr, &buf)) /* file exist? */
{
got_error (FIND_msg, sptr);
continue;
}
else if (!buf.st_size)
{
continue; /* 0 length? */
}
if (!(j = (*callback) (sptr)))
{
fclose (fp);
net_problems = 1;
return FALSE;
}
/*--------------------------------------------*/
/* File was sent. Flag file name */
/*--------------------------------------------*/
fseek (fp, last_start, SEEK_SET);
putc ('~', fp); /* flag it */
fflush (fp);
rewind (fp); /* clear any eof flags */
fseek (fp, current, SEEK_SET);
errno = 0;
if (j == SPEC_COND) /* if "Funny" success, */
continue; /* don't delete/truncate */
if (i == TRUNC_AFTER)
{
CLEAR_IOERR ();
i = open (sptr, O_WRONLY|O_TRUNC, S_IWRITE); /*PLF Wed 06-14-1989 23:59:51 */
got_error (TRUNC_msg, sptr);
status_line (FLAGGING_msg, sptr);
close (i);
}
else if (i == SHOW_DELETE_AFTER)
{
CLEAR_IOERR ();
unlink (sptr);
got_error (UNLINK_msg, sptr);
status_line (UNLINKING_msg, sptr);
}
else if (i == DELETE_AFTER)
{
CLEAR_IOERR ();
unlink (sptr);
got_error (UNLINK_msg, sptr);
}
}
} /* while */
errno = 0;
fclose (fp);
got_error (CLOSE_msg, fname);
unlink (fname);
errno = 0;
} /* !stat */
} /* for */
return TRUE;
}